package com.chag.app.biz.dao.gen;

import com.chag.app.biz.entity.gen.Emp;
import com.chag.app.biz.entity.gen.EmpCriteria;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface EmpMapper {
    int countByExample(EmpCriteria example);

    int deleteByExample(EmpCriteria example);

    @Delete({
        "delete from emp",
        "where empno = #{empno,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(String empno);

    @Insert({
        "insert into emp (empno, ename, ",
        "job, mgr, hiredate, ",
        "sal, comm, deptno)",
        "values (#{empno,jdbcType=BIGINT}, #{ename,jdbcType=VARCHAR}, ",
        "#{job,jdbcType=VARCHAR}, #{mgr,jdbcType=INTEGER}, #{hiredate,jdbcType=TIMESTAMP}, ",
        "#{sal,jdbcType=DOUBLE}, #{comm,jdbcType=DOUBLE}, #{deptno,jdbcType=TINYINT})"
    })
    @SelectKey(statement="select uuid_short()", keyProperty="empno", before=true, resultType=String.class)
    int insert(Emp record);

    int insertSelective(Emp record);

    List<Emp> selectByExample(EmpCriteria example);

    @Select({
        "select",
        "empno, ename, job, mgr, hiredate, sal, comm, deptno",
        "from emp",
        "where empno = #{empno,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    Emp selectByPrimaryKey(String empno);

    int updateByExampleSelective(@Param("record") Emp record, @Param("example") EmpCriteria example);

    int updateByExample(@Param("record") Emp record, @Param("example") EmpCriteria example);

    int updateByPrimaryKeySelective(Emp record);

    @Update({
        "update emp",
        "set ename = #{ename,jdbcType=VARCHAR},",
          "job = #{job,jdbcType=VARCHAR},",
          "mgr = #{mgr,jdbcType=INTEGER},",
          "hiredate = #{hiredate,jdbcType=TIMESTAMP},",
          "sal = #{sal,jdbcType=DOUBLE},",
          "comm = #{comm,jdbcType=DOUBLE},",
          "deptno = #{deptno,jdbcType=TINYINT}",
        "where empno = #{empno,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Emp record);
}